home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 038a / baswiz17.zip / VGABOX.BAS < prev    next >
BASIC Source File  |  1991-04-01  |  5KB  |  114 lines

  1. ' =======================================================
  2. '  VGABOX.BAS  Copyright (c) 1990  Michael Welch
  3. '  included with BasWiz by permission
  4. ' =======================================================
  5. '  Name:  VGABOX.BAS
  6. '  Type:  Main Module
  7. '  Lang:  Microsoft QuickBASIC v4.5
  8. '  Ver:   1.00
  9. '  Date:  10/30/1990
  10. '  By:    Michael Welch of Dallas, Texas
  11. '  Reqs:  Crescent Software's PDQ.LIB
  12. '         Tom Hanlin's BASIC Wizard library
  13. '  Purp:  (multifaceted):
  14. '         1.  To demonstrate the efficiency of Crescent's
  15. '             BCOMxx replacement library for QuickBASIC.
  16. '         2.  To demonstrate the graphics capabilities and
  17. '             extensions of Tom Hanlin's BASIC Wizard
  18. '             library.
  19. '         3.  To demonstrate the color range of the VGA's
  20. '             high-color mode.
  21. '| Mods:  Thomas G. Hanlin III
  22. '|        My modifications were largely a matter of
  23. '|        reformatting the source to appear more like
  24. '|        the other BASWIZ sources, for consistency.
  25. '|        A few other trivial alterations were made.
  26. ' =======================================================
  27.  
  28.    DECLARE FUNCTION BiosInkey% ()      ' PDQ replacement for ASC(INKEY$)
  29.    DECLARE FUNCTION PDQRand% (Range%)  ' PDQ replacement for RND
  30.    DECLARE SUB PDQRandomize (Seed%)    ' PDQ replacement for RANDOMIZE
  31.  
  32.    DECLARE SUB GetDisplay (Adapter%, Mono%)
  33.    DECLARE SUB G13Box (BYVAL X1%, BYVAL Y1%, BYVAL X2%, BYVAL Y2%, BYVAL Fill%)
  34.    DECLARE SUB G13Cls ()
  35.    DECLARE SUB G13Color (BYVAL Foreground%, BYVAL Background%)
  36.    DECLARE SUB G13Mode (BYVAL Graphics%)
  37.  
  38.    DEFINT A-Z                          ' does not need floating point math
  39.  
  40.    GetDisplay Adapter, Mono            ' check adapter type
  41.    IF Adapter < 6 THEN                 ' just end if less than VGA
  42.       PRINT "Sorry, you need a VGA for this demo!"
  43.       END
  44.    END IF
  45.  
  46.    DEF SEG = 0
  47.    z = PEEK(&H41C) + (PEEK(&H41D) AND 127) * 256
  48.    PDQRandomize z                      ' RANDOMIZE based on system timer
  49.  
  50.    PRINT
  51.    PRINT "VGABOX v1.00 ≡ (P) 1990 Mike Welch"
  52.    PRINT "VGA animation demo of 256 colors"
  53.    PRINT "[] Slows down    [] Larger box"        ' <-- won't be able to
  54.    PRINT "[] Speeds up     [] Smaller box"       ' <-- print these chars!
  55.    PRINT "ESC Terminates    Other key, CLS"
  56.    PRINT
  57.    PRINT "Any key continues"
  58.    DO: LOOP UNTIL LEN(INKEY$)
  59.  
  60.    G13Mode 1                            ' SCREEN 13 replacement
  61.  
  62.    ' Altered from S&B4EGA to work with
  63.    ' the new SCREEN 13 mode of BASWIZ
  64.    G13Cls                                  ' clear screen
  65.    BoxSiz = 10                             ' initial box size
  66.    Delay = 10                              ' initial delay rate
  67.    DO                                      ' loop until keypress
  68.       EndLoop = 0                          ' reset Boolean flag
  69.       c = c + 1                            ' increase color counter
  70.       IF c > 246 THEN c = 1                ' reset if out of range (black)
  71.       DO                                   ' derive legal value for animation
  72.          X1 = X1 + Xo                      ' add to x-coord
  73.          Y1 = Y1 + Yo                      ' add to y-coord
  74.          z = PDQRand(2)                    ' used for animation, step value
  75.          IF X1 < 15 THEN                   ' if under x range
  76.             Xo = z                         ' enlarge value
  77.          ELSEIF X1 > 305 THEN              ' if over x range
  78.             Xo = 0 - z - 1                 ' decrease value
  79.          ELSEIF Y1 < 15 THEN               ' if under y range
  80.             Yo = z                         ' enlarge
  81.          ELSEIF Y1 > 185 THEN              ' if over y range
  82.             Yo = 0 - z - 1                 ' decrease
  83.          ELSE
  84.             EndLoop = -1                   ' quit computing and draw box
  85.          END IF
  86.       LOOP UNTIL EndLoop
  87.  
  88.       G13Color c, 0                        ' set color here
  89.       G13Box X1 - BoxSiz, Y1 + BoxSiz, X1 + BoxSiz, Y1 - BoxSiz, c
  90.  
  91.       IF c MOD Delay = 0 THEN CALL Pause(1)' delay 1/18th second
  92.  
  93.       a = BiosInkey                        ' no errors here w/PDQ
  94.       IF a THEN                            ' if a key was pressed
  95.          SELECT CASE a                     ' PDQ: -val for extended key
  96.             CASE -75                       ' left_arrow; slow down
  97.                IF Delay > 1 THEN Delay = Delay - 1
  98.             CASE -77                       ' right_arrow; speed up
  99.                IF Delay < 64 THEN Delay = Delay + 1
  100.             CASE -72                       ' up_arrow; make box larger
  101.                IF BoxSiz < 10 THEN BoxSiz = BoxSiz + 1
  102.             CASE -80                       ' down_arrow; make box smaller
  103.                IF BoxSiz > 2 THEN BoxSiz = BoxSiz - 1
  104.             CASE 27                        ' ESC
  105.                c = 0                       ' set end loop flag
  106.             CASE ELSE                      ' any other key
  107.               G13Cls                       ' clear screen
  108.          END SELECT
  109.       END IF
  110.    LOOP WHILE c
  111.  
  112.    G13Mode 0                               ' restore text mode
  113.    PRINT "";                           ' ANSI "clear screen"
  114.